<?php
/**
 * Created by PhpStorm.
 * Author: QinShuai
 * Email: qinshuai0423@qq.com
 * Date: 2021/6/23
 */

namespace backend\controllers;

use Yii;
use backend\models\AdminRule;
use backend\traits\Controller;

class AdminRoleController extends BaseController
{
    use Controller;

    public function beforeAction($action)
    {
        $rule = (new AdminRule())->getTreeData();
        $this->data['rule'] = json_encode($rule);

        return parent::beforeAction($action);
    }

    public function afterFilter(&$tableData)
    {
        foreach ($tableData as &$val) {
            $val['rule'] = AdminRule::instance()->filterMenu($val['rule']);
        }
    }
}